﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using Gameplay.PVE.Survivor;
using OWL.Rendering.HRP;
using UnityEditor;
using UnityEngine;
using UnityEngine.AI;
using Yoozoo.HRP.Runtime;
using Vector3 = UnityEngine.Vector3;

[CustomEditor(typeof(NavMeshBakeHelper))]
public class NavMeshBakeHelperInspector : Editor
{
    private NavMeshBakeHelper data;

    private void OnEnable()
    {
        data = target as NavMeshBakeHelper;
    }

    public override void OnInspectorGUI()
    {
        if (GUILayout.Button("烘焙并保存"))
        {
            var navMeshData = NavMeshBakeHelper.navMesh;
            NavMeshBakeHelper.BakeNavMesh();
            var path = "Assets/ResourcesAssets/Pve/Survivor/NavMesh/"+data.name+".asset";
            AssetDatabase.DeleteAsset(path);
            AssetDatabase.CreateAsset(navMeshData,path);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath<NavMeshData>(path));
            NavMeshBakeHelper.Clear();
        }

        if (GUILayout.Button("烘焙"))
        {
            NavMeshBakeHelper.BakeNavMesh();
        }
        base.OnInspectorGUI();
    }
    
}